﻿using _1_Interfaces.Interfaces.Cjw;
using _1_Interfaces.Models.Tables.Cjw;
using AutoMapper;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;

namespace _2_Services.Services.Cjw
{
    /// <summary>
    /// 统计每天每个科室的出入科数量服务
    /// </summary>
    public class InOutListService : IInOutListService
    {
        SqlSugarClient _db = CjwDbContext.GetInstance();
        private IMapper _mapper;

        public InOutListService(IMapper mapper)
        {
            _mapper = mapper;
        }

        /// <summary>
        /// 插入出入科记录
        /// </summary>
        /// <param name="departmentId">科室id</param>
        /// <param name="inOut">1入科 2出科</param>
        /// <returns></returns>
        public bool AddInOut(int departmentId, int inOut)
        {
            InOutList inOutList = new InOutList();
            inOutList.DepartmentId = departmentId;
            inOutList.InOut = inOut;
            inOutList.Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            if (_db.Insertable(inOutList).ExecuteCommand() == 1)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}
